package com.sali.service.data_processor.chain.handlers;

import com.alibaba.fastjson.JSONObject;
import com.sali.commons.exception.ProcessChainHandlerInitException;
import com.sali.commons.exception.ProcessChainHandlerProcessException;
import com.sali.entity.ProcessDefinition;
import com.sali.entity.TransferObject;
import com.sali.service.data_processor.chain.IProcessChainHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;

public class DataHandler03 implements IProcessChainHandler {

    public static final Logger log = LoggerFactory.getLogger(IProcessChainHandler.class);

    @Override
    public void preProcess(ProcessDefinition processDefinition) throws ProcessChainHandlerInitException {
        log.info("data handler 03 init...");
    }

    @Override
    public void process(TransferObject input) throws ProcessChainHandlerProcessException {
        log.info("data handler 03 is processing...");
        HashMap<String, Object> data = input.getData();

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("dataField", "data 03");

        data.put("data handler 03", jsonObject.toJSONString());
    }
}
